import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDRandomEventEquipDrop {
	/**序号*/
	id,
	/**关卡*/
	upStageid,
	/**初级武装*/
	dropid,
	/**高级武装*/
	dropid_2,

	/**枚举数量*/
	EnumCount
}



export class CDRandomEventEquipDrop{
	/**序号*/
	public id: number;
	/**关卡*/
	public upStageid: number;
	/**初级武装*/
	public dropid: number;
	/**高级武装*/
	public dropid_2: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDRandomEventEquipDrop.id: return this.id;
			case E_CDRandomEventEquipDrop.upStageid: return this.upStageid;
			case E_CDRandomEventEquipDrop.dropid: return this.dropid;
			case E_CDRandomEventEquipDrop.dropid_2: return this.dropid_2;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDRandomEventEquipDrop.id: this.id = v; break;
			case E_CDRandomEventEquipDrop.upStageid: this.upStageid = v; break;
			case E_CDRandomEventEquipDrop.dropid: this.dropid = v; break;
			case E_CDRandomEventEquipDrop.dropid_2: this.dropid_2 = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDRandomEventEquipDrop> = new HashMap<number, CDRandomEventEquipDrop>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDRandomEventEquipDrop[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDRandomEventEquipDrop();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].upStageid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dropid = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].dropid_2 = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDRandomEventEquipDrop{
		return this.datas ? this.datas.get(id) : null;
	}
}
